package com.jt.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.jt.interceptor.UserInterceptor;

@Configuration
public class MvcConfigurer implements WebMvcConfigurer{
	
	//开启匹配后缀型配置
	@Override
	public void configurePathMatch(PathMatchConfigurer configurer) {
		
		configurer.setUseSuffixPatternMatch(true);
	}
	@Autowired
	private UserInterceptor UserInterceptor;
	//新增拦截器  不登录不允许访问购物车/订单
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		//将自己的拦截器添加到拦截器的注册中心,拦截器需要设置拦截路径
		// /cart/** 购物车的多级目录 /cart/* 购物车的一级目录
		registry.addInterceptor(UserInterceptor)
		.addPathPatterns("/cart/**","/order/**");
	}
}
